package com.zrwl.poscloud.core.security;

import com.zrwl.poscloud.base.entity.Admin;
import com.zrwl.poscloud.xo.service.AdminRoleService;
import com.zrwl.poscloud.xo.service.AdminService;
import com.zrwl.poscloud.xo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 将SpringSecurity中的用户管理和数据库的管理员对应起来
 *
 * @author liusitong
 * @date 2020/9/14 10:43
 */
@Service
public class SecurityUserDetailsServiceImpl implements UserDetailsService {


    /**
     * @param username 浏览器输入的用户名【需要保证用户名的唯一性】
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Admin admin=new Admin();
        admin.setUserName(username);
        return SecurityUserFactory.create(admin);
    }
}
